using AiQiuQuan.Sport.Model.Models;
using AiQiuQuan.Sport.Core;
using AiQiuQuan.Sport.WebApi.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;

namespace AiQiuQuan.Sport.WebApi.Controllers
{
    /// <summary>
    /// 基础数据管理
    /// </summary>
    [AllowAnonymous]
    public class BaseDataController : ApiController
    {
        private readonly IBaseDataService _baseDataService;

        /// <summary>
        /// 管理
        /// </summary>
        public BaseDataController(
            IBaseDataService baseDataService)
        {
            _baseDataService = baseDataService;
        }

        /// <summary>
        /// 省份列表
        /// </summary>
        [HttpGet("list_province")]
        public async Task<UnaryResult<List<BaseDataDto>>> GetProvinceListAsync()
        {
            var result = await _baseDataService.GetProvinceListAsync();
            return UnaryResult.Succeed(result);
        }

        /// <summary>
        /// 城市列表
        /// </summary>
        /// <param name="provinceId">省份ID</param>
        [HttpGet("list_city")]
        public async Task<UnaryResult<List<BaseDataDto>>> GetCityListAsync(Guid? provinceId)
        {
            var result = await _baseDataService.GetCityListAsync(provinceId);
            return UnaryResult.Succeed(result);
        }
    }
}
